<meta http-equiv="Content-type" content="text/html" charset="UTF-8">
<head>
    <#include "../../common/header.ftl">

    <title>需要退款的订单列表</title>
</head>
<body>
<div class="content-wrapper" style="display: flex">
    <div class="nav-wrapper" style="flex: 0 0 200px;width: 200px">
            <#include "../../common/nav.ftl">
    </div>
    <div id="page-content-wrapper" style="flex: 1;margin-left: 20px;margin-top: 100px">
        <div class="col-md-12 column">
            <table class="table" table-bordered style="margin-top: 20px">
                <thead>
                <tr>
                    <th>
                        订单id
                    </th>
                    <th>
                        姓名
                    </th>
                    <th>
                        订单总价
                    </th>
                    <th>
                        地址
                    </th>
                    <th>
                        创建时间
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>
            <tbody>
                    <#list pages.getContent() as pageItem>
                    <tr class="success">
                        <td>
                            ${pageItem.orderId}
                        </td>
                        <td>
                            ${pageItem.buyerName}
                        </td>
                        <td>
                            ${pageItem.orderAmount}
                        </td>
                        <td>
                            ${pageItem.buyerAdderss}
                        </td>
                        <td>
                            ${pageItem.createTime}
                        </td>
                        <td>
                            同意:<input type="radio" name="isAgree" value="true"/>
                            拒绝:<input type="radio" name="isAgree" value="false"/>
                            <input type="button" value="确认选择"
                                   onclick="isAgree('${pageItem.orderId}','${pageItem.orderAmount}')">
                        </td>
                    </tr>
                </tbody>
                    </#list>
            </table>
            <ul class="pagination pull-right">

            <#-- <!--显示待退款订单列表&ndash;&gt;
                 <#list pages.getContent() as pageItem>
                     订单id：  ${pageItem.orderId}<br>
                     姓名:     ${pageItem.buyerName}
                     订单总价： ${pageItem.orderAmount}<br>
                     地址：    ${pageItem.buyerAdderss}<br>
                     创建时间：${pageItem.createTime}<br>
                     同意:<input type="radio" name="isAgree" value="true" />
                     拒绝:<input type="radio" name="isAgree" value ="false"/>
                     <input type="button" value="确认选择" onclick="isAgree('${pageItem.orderId}','${pageItem.orderAmount}')">
                     <br>
                     <br>
                 </#list>
     -->
                <!--显示上一页-->
            <#if currentPage lt 2>
                        <li class="disabled"><a href="#">上一页</a></li>
            <#else>
                        <li>
                            <a href="/sell/order/admin/findpaybackorderlist?currentPage=${currentPage - 1}&size=${size}&openid=${openid}">上一页</a>
                        </li>
            </#if>

                <!--显示当前页-->
            <#list 1..pages.getTotalPages() as index>
                <#if index == 0>
                <#elseif currentPage == index>
                    <li class="disabled"><a href="#">${index}</a></li>
                <#else>
                    <li>
                        <a href="/sell/order/admin/findpaybackorderlist?currentPage=${index}&size=${size}&openid=${openid}">${index}</a>
                    </li>
                </#if>
            </#list>

                <!--显示下一页-->
             <#if currentPage gte pages.getTotalPages()>
                        <li class="disabled"><a href="#">下一页</a></li>
             <#else>
                        <li>
                            <a href="/sell/order/admin/findpaybackorderlist?currentPage=${currentPage + 1}&size=${size}&openid=${openid}">下一页</a>
                        </li>
             </#if>
            </ul>
        </div>
    </div>
</div>

<script>
    function isAgree(orderId, orderAmount) {
        var openid = "${openid}";
        var radios = document.getElementsByName("isAgree");
        var selectValue = null;
        for (var i = 0; i < radios.length; i++) {
            if (radios[i].checked == true) {
                selectValue = radios[i].value;
            }
        }
        alert(selectValue);
        if (selectValue == null) {
            alert("请选择是否退款!");
        } else if (selectValue == "true") {
            alert("退款成功");
            this.location.href = "/sell/pay/admin/refund?openid=" + openid + "&orderId=" + orderId + "&orderAmount=" + orderAmount;
        } else {
            var NoAgree = false;
            this.location.href = "/sell/order/admin/agreepayback?openid=" + openid + "&orderId=" + orderId + "&isAgree=" + NoAgree;
        }
    }
</script>
</body>

